package com.lunatic.assistant.controller;

import com.alibaba.cloud.ai.dashscope.rag.DashScopeCloudStore;
import org.springframework.ai.document.Document;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class StoreController {

    private final DashScopeCloudStore dashScopeCloudStore;

    @Autowired
    public StoreController(DashScopeCloudStore dashScopeCloudStore) {
        this.dashScopeCloudStore = dashScopeCloudStore;
    }

    @GetMapping("/ai/search")
    public List<Document> store(@RequestParam(value = "message", defaultValue = "What's spring ai") String message) {
        return this.dashScopeCloudStore.similaritySearch(message);
    }
}